package com.android.sunflower.logic

import android.app.Application
import androidx.room.Room
import com.android.sunflower.logic.room.AppDataBase
import com.android.sunflower.logic.room.DBSingleton
import com.android.sunflower.logic.room.daos.PlantedFDao
import com.android.sunflower.logic.room.entities.Flower
import com.android.sunflower.logic.room.entities.PlantedF
import com.android.sunflower.ui.MainActivity

object Repository {
    private val db=DBSingleton.getInstance()
    private val flowerDao=db.flowerDao()

    private val plantedFDao=db.plantedFDao()

    fun insertFlowers(vararg fls:Flower){
        for(f in fls) flowerDao.insertFlowers(f)
    }

    fun selectAllFlower():List<Flower>{
        return flowerDao.selectAll()
    }

    fun insertPlantF(vararg pls:PlantedF){
        for(pl in pls) plantedFDao.insertPlantedF(pl)
    }

    fun selectAllPlatedF():List<PlantedF>{
        return plantedFDao.selectAll()
    }

    fun selectFlowerByName(name:String):List<Flower>{
        return flowerDao.selectByName(name)
    }

    fun deletePlantF(pl:PlantedF){
        plantedFDao.delete(pl)
    }

    fun updatePlatedF(pl:PlantedF){
        plantedFDao.update(pl)
    }
}